﻿using System;
using System.Collections.Generic;

using FireBus.Contracts;


namespace FireBus.Core
{
	public class ExtensionLoadResult
	{
		private readonly Extension _Extension;

		private readonly IList<ExtensionLoadError> _Errors;


		public Extension Extension
		{
			get { return _Extension; }
		}

		public IEnumerable<ExtensionLoadError> Errors
		{
			get { return _Errors; }
		}

		public Boolean Failed
		{
			get { return _Errors.Count > 0; }
		}


		public ExtensionLoadResult(
			Extension extension,
			IEnumerable<ExtensionLoadError> errors)
		{
			if (errors == null)
			{
				errors = new ExtensionLoadError[0];
			}
			_Errors = new List<ExtensionLoadError>(errors);
			if (_Errors.Count == 0)
			{
				if (extension == null)
				{
					throw new ArgumentNullException("extension");
				}
				_Extension = extension;
			}
		}
	}
}
